package com.qzsoft.zhjd.machine.modules.machinereport.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.machine.modules.machinereport.dto.MachineReportUseRateDeptDto;
import com.qzsoft.zhjd.machine.modules.machinereport.dto.MachineReportUseRateDto;
import com.qzsoft.zhjd.machine.modules.machinereport.service.MachineReportUseRateService;

/**
 * @ClassName MachineReportUseRateController
 * @Description 设备使用率控制器
 * @author linhuawei
 * @since 2021-11-09
 */
@RestController
@RequestMapping("/api/machineReportUseRate")
public class MachineReportUseRateController {

    @Autowired
    private MachineReportUseRateService machineReportUseRateService;

    /**
     * @Title machine
     * @Description 按照机械设备进行统计
     * @param params 查询条件
     * @return 统计列表
     */
    @GetMapping("/machine")
    public Result<IPage<MachineReportUseRateDto>> machine(@RequestParam Map<String, Object> params) {
        IPage<MachineReportUseRateDto> page = machineReportUseRateService.machine(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title dept
     * @Description 按照机构进行统计
     * @param params 查询条件
     * @return 统计数据
     */
    @RequiresPermissions("api:machineReportUseRate:count")
    @GetMapping("/dept")
    public Result<MachineReportUseRateDeptDto> dept(@RequestParam Map<String, Object> params) {
        MachineReportUseRateDeptDto data = machineReportUseRateService.dept(params);
        return ResultUtils.ok(data);
    }

}
